package ar.com.digitalbricks.view.imprenta.cliente.action;

import java.io.File;
import java.util.Collection;

import ar.com.digitalbricks.view.imprenta.helper.ClienteView;
import ar.com.digitalbricks.view.imprenta.helper.ContactoView;

import com.opensymphony.xwork2.Action;

public class CrearCliente extends ClienteAction {
	
	private File[] file;
    private String[] contentType;
    private String[] filename;
	
	@SuppressWarnings("unchecked")
	public String execute() throws Exception {
		this.getClienteView().setContactos((Collection<ContactoView>) session.get("contactos"));
		String id = this.getClienteMgr().crearCliente(this.getClienteView());
		this.getClienteView().setId(id);
		this.getCurrentTransaction().commit();
		return Action.SUCCESS;
	}
	
	public String preparar() throws Exception {
		this.setClienteView(new ClienteView());
		this.setShowContactoDiv(false);
		return Action.INPUT;
	}
	
	public String upload() throws Exception {
		this.getFile();
		this.getContentType();
		this.getFilename();
		return Action.INPUT;
	}
	
	public File[] getFile() {
		return this.file;
	}

	public void setFile(File[] file) {
		this.file = file;
	}

	public String[] getContentType() {
		return this.contentType;
	}

	public void setContentType(String[] contentType) {
		this.contentType = contentType;
	}

	public String[] getFilename() {
		return this.filename;
	}

	public void setFilename(String[] filename) {
		this.filename = filename;
	}
}